package com.dgz.test.controller;

import org.springframework.ai.image.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: DongGuoZhen
 * @Date: 2025/07/22/14:19
 * @Description:
 */

//对话模型 文生图
@RestController
@RequestMapping("/image-model")
public class ImageModelController {

    private ImageModel imageModel;

    public ImageModelController(ImageModel imageModel) {
        this.imageModel = imageModel;
    }

    @RequestMapping("/model")
    public String model(String input) {
//        设置图片相关参数
        ImageOptions options = ImageOptionsBuilder.builder()
                .model("wanx2.1-t2i-turbo")
                .height(1024)
                .width(1024)
                .build();
        ImagePrompt prompt = new ImagePrompt(input,options);
        ImageResponse call = imageModel.call(prompt);
        String url = call.getResult().getOutput().getUrl();
        return url;
    }
}
